package com.coocaa.aries.core.tool.file;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ArrayUtils;

import java.io.File;
import java.io.IOException;

/**
 * @author : bijiahao
 * @date : 2019/6/5.
 * @description:<p> 文件操作-删除等
 * </p>
 */
public class FileOpsUtil {

    /**
     * 删除指定目录和指定文件
     *
     * @param dir
     * @param filePath
     */
    public static void delete(String dir, String... filePath) {
        try {
            File dirFile = new File(dir);
            FileUtils.deleteDirectory(dirFile);
            deleteBatch(filePath);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void deleteBatch(String... filePath) {
        if (ArrayUtils.isNotEmpty(filePath)) {
            for (String path : filePath) {
                FileUtils.deleteQuietly(new File(path));
            }
        }
    }


    public static void main(String[] args) {
        delete("/Users/bijiahao/log/cg/123234657");
    }
}
